<?php
/**
*
* @package phpBB3
* @version $Id: index.php 8479 2008-03-29 00:22:48Z naderman $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/functions_link.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/link');
$id = request_var('link', '');

if(!$config['enable_cryptlink'])
{
    trigger_error($user->lang['CRYPTLINK_DEACTIVETED']);
}
if($id == '')
{
    trigger_error($user->lang['NO_LINK_ID']);
}
$sql = "SELECT * FROM " . LINK_TABLE . "
    WHERE id = '" . $db->sql_escape($id)  . "'";

$result = $db->sql_query_limit($sql, 1);

if($row = $db->sql_fetchrow($result))
{
    if(strpos($row['url'], $config['server_name']) !== false)
    {
        if($config['auto_redirect_intern'])
        {
            ($config['auto_redirect_time_intern']) ? meta_refresh($config['auto_redirect_intern'], append_sid($row['url'])) : redirect($row['url']);
            trigger_error(sprintf($user->lang['AUTO_REDIRECT_TIME_INTERN'], append_sid($row['url']), $config['auto_redirect_intern']));
        }
        trigger_error(sprintf($user->lang['REDIRECT_INTERN'], append_sid($row['url']), $time));
    }
    else
    {
        if($config['auto_redirect_extern'])
        {
            ($config['auto_redirect_time_extern']) ? meta_refresh($config['auto_redirect_extern'], $row['url']) : redirect($row['url']);
            trigger_error(sprintf($user->lang['AUTO_REDIRECT_TIME_EXTERN'], $row['url'], $config['auto_redirect_extern']));
        }
        trigger_error(sprintf($user->lang['REDIRECT_EXTERN'], $row['url'], $time));
    }

}
else
{
    trigger_error(sprintf($user->lang['NO_MATCH'], $id));
}
$db->sql_freeresult($result);

?>